
import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from '@nestjs/common';
import { HandpicDeviceService } from './handpic-device.service';
import { Public } from 'src/decorations/public.decorator';
import { ApiTags } from '@nestjs/swagger';
import { RoleGuard } from 'src/guards/role.guard';
import { Roles } from 'src/decorations/role.decorator';
import { IPaginationFormWithCondition } from 'types/requestParams';
import { HandpicDevice } from '@libs/db/models/handpic-device.model';

@ApiTags('菜单')
@Controller('handpic-device')
// @UseGuards(RoleGuard) // 是否需要角色守卫，如果需要特殊权限才能访问接口，需要在对应请求前加@Roles(['admin', 'manage'])
export class HandpicDeviceController {
  constructor(private readonly handpicDeviceService: HandpicDeviceService) {}

  // 增
  @Post('create')
  create(@Body() body: HandpicDevice) {
    return this.handpicDeviceService.create(body);
  }

  // 删
  @Delete('delete/:id')
  remove(@Param('id') id: string) {
    return this.handpicDeviceService.remove(id);
  }

  // 改
  @Post('update')
  update(@Body() body: HandpicDevice) {
    return this.handpicDeviceService.update(body);
  }

  // 查
  @Post('findWidthCondition')
  findWidthCondition(@Body() body: IPaginationFormWithCondition) {
    return this.handpicDeviceService.findWidthCondition(body); 
  }

  // 根据id查详情
  @Get('findById/:id')
  findById(@Param('id') id: string) {
    return this.handpicDeviceService.findById(id);
  }
}
  